﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Webcar.BLL;
using ToolsLayer;
using System.Data;

namespace Webcar.UI
{
    public partial class RecentWorkReport : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.IsPostBack) return;
                //string sql = "select top 14 * from v_report where dept_code in (select dept_code from bs_man_dept where man_code='" +
                //    UserBLL.LoginUserID + "')";
                string ny = DateTime.Now.ToString("yyyy-MM");
                //ny = "2008-03";
                string sql = "select * from v_report where  ny='" + ny + "'";
                this.Repeater1.DataSource = DB.ExecuteDataset(sql); 
                this.Repeater1.DataBind();
                if (DateTime.Now.Day >= 25)
                {
                    //未上报人员
                    string sql2 = "select *,'"+ny+"' as ny" +" from dept where isnull(del_flag,'F')='F' and dept_code not in (select dept_code from v_report where ny='" + ny + "')";
                    this.Repeater2.DataSource = DB.ExecuteDataset(sql2);
                    this.Repeater2.DataBind();
                }
            }
            catch (Exception ex)
            {
                new CurrentUser().LogError(ex);
            }

        }

        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            HyperLink link = (HyperLink)e.Item.FindControl("hyperlink1");
            if (link == null) return;
            DataRowView row = e.Item.DataItem as DataRowView;
            string url = "UI/ReportPopView.aspx?id=" + row["xh"].ToString();
            link.NavigateUrl = "javascript:openDialog('" + url + "',550,300);";

            Label label = (Label)e.Item.FindControl("newlabel");
            InfoChecker ic = new InfoChecker();
            label.Visible = !ic.InfoIsRead(row["xh"].ToString(), InfoCheckType.Report);

        }

    }
}